<template>
  <div class="source-main">
    <div class="com-header">
        <button class="back" @click="$router.go(-1)"><i></i></button>
        <span>选择来源</span>
    </div>
    <!-- 网页内容区域 -->
    <div class="view-content">
       <div class="wrapper">
            <ul>
                <router-link tag="li" class="justify-align-center" :to="{path:'/read',query:{novelId:sourceData.novelId,chapterId:sourceData.chapterId,cId:sourceData.cId,siteId:item.siteid}}" v-for="(item,index) in dataArr" :key="index">
                    <div class="left"><i class="icon">{{item.sitename.substring(0,1)}}</i></div>
                    <div class="right">
                        <p class="ellipsis">{{item.sitename}}</p>
                        <p class="info">
                            <span class="ellipsis title">{{item.last}}</span>
                            <span class="time">{{item.lasttime}}</span>
                        </p>
                    </div>
                </router-link>
            </ul>
       </div>
    </div>
  </div>
</template>

<script>
  import {Toast} from 'mint-ui'
  import api from '~/plugins/api.js'
  import axios from 'axios'
  export default {
    head() {
        return {
            title: `快眼看书`,
            meta: [{
                name: 'description',
                content: `快眼看书专注于小说搜索.`
            },{
                name: 'keyWords',
                content: `快眼看书`
            }]
        }
    },
    data () {
      return {
          dataArr: [],
          sourceData:{}
      }
    },
    created() {
        this.getSourceList()
    },
    computed: {
        iconStr: function() {
           // return item.sitename.substring(0,1)
        }
    },
    methods: {
        async getSourceList () {
            let {query} = this.$route
            this.sourceData = query
            let res = await axios.get(api.sourceList,{params:query})
            if(res){
                this.dataArr = res.data.data
            }
        }
    }
  }
</script>
